using System;

namespace Sessionizer.Core
{
    /// <summary>
    /// Represents an instance of Session
    /// </summary>
    public interface ISession : IDisposable
    {
        /// <summary>
        /// Creates an ISessionBinding used to bind session as current inside "using" scope.
        /// </summary>
        /// <returns></returns>
        ISessionBinding Bind();


        /// <summary>
        /// Sets a session's data instance.
        /// Once set value can not be changed.
        /// Throws InvalidOperationException if already registred.
        /// </summary>
        /// <typeparam name="TData">Type of data</typeparam>
        void Set<TData>(TData instance);

        /// <summary>
        /// Gets or creates a session's data instance.
        /// </summary>
        /// <typeparam name="TData">Type of data</typeparam>
        /// <returns>Data</returns>
        TData Get<TData>();
    }
}